<?php
class PsychologistsMeta extends CActiveRecord {
	const KEY_QQCODE = 'qqCode';
	const KEY_DIRECTION = 'direction';
	
	public static function model($className = __CLASS__) {
		return parent::model($className);
	}

	public function tableName() {
		return strtolower('PsychologistsMeta');
	}

	public function rules() {
		return array(
			array('psychologistId, metaKey', 'required')
		);
	}
	
	public function findByMetaKey($metaKey, $psychologist) {
		return self::model()->find('metaKey = ? AND psychologistId = ?', array($metaKey, $psychologist->psychologistId));
	}

	public function relations() {
		return array(
			'psychologist' => array(self::BELONGS_TO, 'Psychologists', 'psychologistId')
		);
	}
}
